<script setup lang="ts">
import { toRefs, watch } from 'vue'
// interface Props {
//   show: boolean;
//   title: string
// }
// withDefaults(defineProps<Props>(), {
//   show: false,
//   title: ''
// })
const props = defineProps({
  show: {
    type: Boolean,
    default: false
  },
  title: {
    type: String,
    default: 'ccc'
  },
  content: {
    type: String,
    default: ''
  }
})
const { title, show, content } = toRefs(props)
watch(show, (val) => {
  document.getElementsByTagName('body')[0].className = val ? 'hidden' : ''
})
const emit = defineEmits(['close'])
const handleClose = () => {
  emit('close')
}
</script>

<template>
  <div class="popup-shadow" v-show="show">
    <div class="popup-box">
      <div class="title">{{ title }}</div>
      <div class="close" @click="handleClose"></div>
      <div class="content">
        <slot>
          <div v-html="content"></div>
        </slot>
      </div>
    </div>
  </div>
</template>

<style lang="scss" scoped>
.popup-shadow {
  z-index: 200;
  position: fixed;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: rgba($color: #000000, $alpha: .4);
  display: flex;
  justify-content: center;
  align-items: center;
}

.popup-box {
  position: relative;
  width: 900px;
  padding: 80px 0;
  background-color: #fff;
  border-radius: 28px;
  max-height: 90vh;

  .close {
    position: absolute;
    top: 20px;
    right: 40px;
    width: 40px;
    height: 40px;
    background-image: linear-gradient(to right, #3888FF, #6c71FF, #AA58FA, #FB6D86);
    border-radius: 50%;
    cursor: pointer;
    transform: rotate(45deg);
    transition: all .3s;

    &:hover {
      transform: rotate(225deg);
    }

    &::after,
    &::before {
      content: '';
      position: absolute;
      left: 50%;
      top: 50%;
      background-color: #fff;
      transform: translate(-50%, -50%);
    }

    &::before {
      width: 2px;
      height: 24px;
    }

    &::after {
      width: 24px;
      height: 2px;
    }
  }

  .title {
    position: absolute;
    left: 50px;
    top: 25px;
    font-size: 24px;
    color: #222;
    font-weight: 700;
    line-height: 30px;
  }

  .content {
    min-height: 400px;
    max-height: calc(90vh - 160px);
    padding: 0 50px;
    line-height: 32px;
    color: #9195A3;
    overflow-y: auto;
  }
}
</style>